cmake_minimum_required(VERSION 2.8)

set(asynio_src 	dllmain.cpp 
				filereadimpl.cpp
				filewriteimpl.cpp
				asynframeimpl.cpp
				asynctcpsocketimpl.cpp
				tcpsocketimpl.cpp
				iooperationimpl.cpp)


file(GLOB iouv_src "ioimpl/*.cpp")
	
if (${UNIX_OS})
	include_directories(
		${PROJECT_SOURCE_DIR}/include
		${PROJECT_SOURCE_DIR}/extensions/include
		${by3rd_library_include}
		/usr/local/include
		/opt/include
		/usr/include
		)

elseif (${WIN_OS})

else()

endif()

link_directories(/opt/local/lib)
link_directories(/opt/lib)
link_directories(${PROJECT_SOURCE_DIR}/lib//${CMAKE_BUILD_TYPE}/)

set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})

add_library(asynio SHARED ${asynio_src} ${iouv_src})

set_target_properties(asynio PROPERTIES OUTPUT_NAME "asynio")

set(CMAKE_CXX_FLAGS "-std=c++11")

set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -fPIC -Wl,--no-as-needed -std=c++11 -frtti -Wall -Werror -fexceptions")

if(CMAKE_BUILD_TYPE STREQUAL Debug)
	set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-g3")
endif()

if(CMAKE_BUILD_TYPE STREQUAL Release)
	set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-O3")
endif()

target_link_libraries(asynio dl)
target_link_libraries(asynio pthread)
target_link_libraries(asynio libevent.a)
target_link_libraries(asynio base)

install(TARGETS asynio 
	LIBRARY DESTINATION bin
	ARCHIVE DESTINATION bin)
